package cn.lhx.blog.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;

import cn.lhx.blog.pojo.ArticleCategory;

public class DaoArticCatg extends BasicDao{

	@Override
	public int delete(int id) {
		ArticleCategory catg=(ArticleCategory)getHibernateTemplate().load(ArticleCategory.class, id);
		getHibernateTemplate().delete(catg);
		return id;
	}

	@Override
	public List<?> executeQuery(String sql) {
		return this.executeQuery(sql, 0);
	}
	public List<?> executeQuery(String sql,int type) {
		//if(HQL_TYPE)
		Query query =getSessionFactory().getCurrentSession().createQuery(sql);
		List list=query.list();
		return list;
	}

	@Override
	public int executeUpdate(String sql) {
		return this.executeUpdate(sql, 0);
	}
	public int executeUpdate(String sql,int type) {
		Query query =getSessionFactory().getCurrentSession().createQuery(sql);
		return query.executeUpdate();
	}

	@Override
	public Object getById(int id) {
		 ArticleCategory arCategory=(ArticleCategory)getHibernateTemplate().get(ArticleCategory.class, id);
		return arCategory;
	}

	@Override
	public List<?> getList(int begin, int size) {
		return null;
		
	}

	@Override
	public Object insert(Object obj) {
		ArticleCategory catg=(ArticleCategory) obj;
		getHibernateTemplate().persist( catg);
		return catg;
	}

	@Override
	public Object update(Object obj) {
		ArticleCategory catg=(ArticleCategory) obj;
		getHibernateTemplate().merge(catg);
		return catg;
	}

}
